//
// Created by andryu on 2025/1/1.
//
#include "ShaderLoader.h"
#include <string>

#define LOG_TAG "LabelSimple"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)

GLuint ShaderLoader::loadShader(GLenum type, const char *shaderCode) {
    GLuint shader = glCreateShader(type);
    glShaderSource(shader,1,&shaderCode, nullptr);
    glCompileShader(shader);

    GLint compiled;
    glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
    if (!compiled){
        GLchar infoLog[512];
        glGetShaderInfoLog(shader, 512, nullptr,infoLog);
        LOGD("Could not compiler shader %d: %s", type, infoLog);
        glDeleteShader(shader);
        return 0;
    }
    return shader;
}
